package com.vf.cloud.rendering.common.scheduled;

import java.util.TimerTask;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class TimerExample {
    public static void main(String[] args) {
        // 创建定时器任务
        TimerTask timerTask1 = new TimerTask() {
            @Override
            public void run() {
                System.out.println("Hello world!>>>>1");
            }
        };
        
        TimerTask timerTask2 = new TimerTask() {
            @Override
            public void run() {
                System.out.println("Hello world!>>>>2");
            }
        };
 
        ScheduledExecutorService scheduledThreadPool = Executors.newScheduledThreadPool(2);
        scheduledThreadPool.scheduleAtFixedRate(timerTask1,1000,  1000, TimeUnit.MILLISECONDS);
        scheduledThreadPool.scheduleAtFixedRate(timerTask2,1000,  1000, TimeUnit.MILLISECONDS);
        //scheduledThreadPool.scheduleAtFixedRate(timerTask, 1000, 1000, TimeUnit.MILLISECONDS);
        
    }
 
}
